package com.esri.core.tasks.geocode;

import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.Geometry;
import com.esri.core.geometry.GeometryEngine;
import com.esri.core.geometry.MapGeometry;
import com.esri.core.geometry.Point;
import com.esri.core.geometry.SpatialReference;
import com.esri.core.internal.util.d;
import com.esri.core.io.EsriServiceException;
import java.util.HashMap;
import java.util.Map;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonToken;

/* loaded from: classes.dex */
public class LocatorGeocodeResult extends LocatorResult {
    private String address;
    HashMap<String, String> attributes = new HashMap<>();
    private Envelope extent;
    private int score;

    @Override // com.esri.core.tasks.geocode.LocatorResult
    public /* bridge */ /* synthetic */ Point getLocation() {
        return super.getLocation();
    }

    @Override // com.esri.core.tasks.geocode.LocatorResult
    public /* bridge */ /* synthetic */ SpatialReference getSpatialreference() {
        return super.getSpatialreference();
    }

    @Override // com.esri.core.tasks.geocode.LocatorResult
    public /* bridge */ /* synthetic */ void setSpatialreference(SpatialReference spatialReference) {
        super.setSpatialreference(spatialReference);
    }

    public String getAddress() {
        return this.address;
    }

    public int getScore() {
        return this.score;
    }

    public Envelope getExtent() {
        return this.extent;
    }

    public Map<String, String> getAttributes() {
        return this.attributes;
    }

    @Override // com.esri.core.tasks.geocode.LocatorResult
    public int hashCode() {
        String str = this.address;
        int hashCode = ((str == null ? 0 : str.hashCode()) + 31) * 31;
        HashMap<String, String> hashMap = this.attributes;
        return ((((hashCode + (hashMap == null ? 0 : hashMap.hashCode())) * 31) + (this.location != null ? this.location.hashCode() : 0)) * 31) + this.score;
    }

    @Override // com.esri.core.tasks.geocode.LocatorResult
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj != null && getClass() == obj.getClass()) {
            LocatorGeocodeResult locatorGeocodeResult = (LocatorGeocodeResult) obj;
            String str = this.address;
            if (str == null) {
                if (locatorGeocodeResult.address != null) {
                    return false;
                }
            } else if (!str.equals(locatorGeocodeResult.address)) {
                return false;
            }
            HashMap<String, String> hashMap = this.attributes;
            if (hashMap == null) {
                if (locatorGeocodeResult.attributes != null) {
                    return false;
                }
            } else if (!hashMap.equals(locatorGeocodeResult.attributes)) {
                return false;
            }
            if (this.location == null) {
                if (locatorGeocodeResult.location != null) {
                    return false;
                }
            } else if (!this.location.equals(locatorGeocodeResult.location)) {
                return false;
            }
            return this.score == locatorGeocodeResult.score;
        }
        return false;
    }

    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("GeocodeResult [address=");
        sb.append(this.address);
        sb.append(", location=[");
        if (this.location != null) {
            sb.append(this.location.getX() + ", " + this.location.getY());
        }
        sb.append("], score=");
        sb.append(this.score);
        sb.append(", attributes=");
        sb.append(this.attributes);
        sb.append(", spatialReference=");
        sb.append("[");
        if (this.spatialreference != null) {
            sb.append(this.spatialreference.getID());
            sb.append(",");
            sb.append(this.spatialreference.getText());
        }
        sb.append("]");
        sb.append("]");
        return sb.toString();
    }

    public static LocatorGeocodeResult fromJson(JsonParser jsonParser) throws Exception {
        if (!d.c(jsonParser)) {
            throw new EsriServiceException("This response cannot be parsed.");
        }
        LocatorGeocodeResult locatorGeocodeResult = new LocatorGeocodeResult();
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String currentName = jsonParser.getCurrentName();
            jsonParser.nextToken();
            if ("address".equals(currentName)) {
                locatorGeocodeResult.address = jsonParser.getText();
            } else if ("name".equals(currentName)) {
                locatorGeocodeResult.address = jsonParser.getText();
            } else if ("extent".equals(currentName)) {
                MapGeometry e = d.e(jsonParser);
                if (e != null) {
                    locatorGeocodeResult.extent = (Envelope) e.getGeometry();
                }
            } else if ("feature".equals(currentName)) {
                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                    String currentName2 = jsonParser.getCurrentName();
                    jsonParser.nextToken();
                    if ("geometry".equals(currentName2)) {
                        MapGeometry jsonToGeometry = GeometryEngine.jsonToGeometry(jsonParser);
                        locatorGeocodeResult.location = jsonToGeometry != null ? (Point) jsonToGeometry.getGeometry() : null;
                    } else if ("attributes".equals(currentName2)) {
                        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                            String currentName3 = jsonParser.getCurrentName();
                            jsonParser.nextToken();
                            locatorGeocodeResult.attributes.put(currentName3, jsonParser.getText());
                        }
                        String str = locatorGeocodeResult.attributes.get("Score");
                        if (str != null) {
                            try {
                                locatorGeocodeResult.score = Integer.parseInt(str.trim());
                            } catch (Exception unused) {
                            }
                        }
                    }
                }
            } else if ("location".equals(currentName)) {
                locatorGeocodeResult.location = (Point) GeometryEngine.jsonToGeometry(jsonParser).getGeometry();
            } else if ("score".equals(currentName)) {
                locatorGeocodeResult.score = jsonParser.getIntValue();
            } else if ("attributes".equals(currentName)) {
                while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                    String currentName4 = jsonParser.getCurrentName();
                    jsonParser.nextToken();
                    locatorGeocodeResult.attributes.put(currentName4, jsonParser.getText());
                }
            } else {
                jsonParser.skipChildren();
            }
        }
        locatorGeocodeResult.attributes.remove("Score");
        return locatorGeocodeResult;
    }

    void setSpatialReference(String str) {
        this.spatialreference = SpatialReference.create(str);
    }

    void setAttributes(String[] strArr) {
        if (strArr != null) {
            for (int i = 0; i < strArr.length - 1; i += 2) {
                this.attributes.put(strArr[i], strArr[i + 1]);
            }
        }
    }

    void setPoint(byte[] bArr) {
        this.location = bArr == null ? null : (Point) GeometryEngine.geometryFromEsriShape(bArr, Geometry.Type.POINT);
    }

    void setScore(int i) {
        this.score = i;
    }

    void setExtent(byte[] bArr) {
        this.extent = bArr == null ? null : (Envelope) GeometryEngine.geometryFromEsriShape(bArr, Geometry.Type.ENVELOPE);
    }

    void setAddress(String str) {
        this.address = str;
    }
}
